<template>
  <div id="app">
    <el-form ref="form" :model="form" label-width="80px">
      <!-- content -->
      <ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
      <el-button type="primary" @click="submitArticle">保存</el-button>
    </el-form>
  </div>

</template>

<script>
import CKEditor from "@ckeditor/ckeditor5-vue2";
import Editor from "ckeditor5-custom-build/build/ckeditor";
import Vue from "vue";
import upload from "./ckeditorPlugin.vue";

// const upload = require("@/assets/js/ckeditorUplodImg5");

Vue.use(CKEditor); //全局注册

export default {
  name: "app",
  data() {
    return {
      // uploadLoaction: "",
      form: {
        content: "",
      },
      editor: Editor,
      editorData: "", //内容的初始值
      editorConfig: {
        // 相关配置.
        language: "zh-cn", //简体中文显示
        placeholder: "正文", //默认填充内容
        //其他配置
        extraPlugins: [upload.MyCustomUploadAdapterPlugin], //图片上传
      },
    };
  },
  created() {
    // this.uploadLoaction =
    //   this.$baseUrl + "/cncec-threepart/fileUpload/newsCoverUpload";
  },

  methods: {
    submitArticle() {
      this.form.content = this.editorData;
      // 空的内容会自动去掉

      console.log(JSON.stringify(this.form));
    },
  },
};
</script>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

